<?php 
include_once ('../global.php');
$pl_id = $_GET['pl_id'];
$sex_id = $players['playerSex'][$pl_id];
$mp_class =$players['playerClass'][$pl_id];
$color = (($mp_class == 414) ? '#333333' :( ($mp_class == 415) ? '#1067ac' : (($mp_class == 416) ? '#d90011' : '#dd9a01')));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link href="<?php echo CSS_PATH?>main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?php echo JS_PATH?>jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH?>main.js"></script>
<title><?php echo $players['playerName'][$pl_id];?>-成绩卡-<?php echo $match_cn_name;?>-Scoring By 斯科云科技</title>
<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js "></script>
 
<script>
    var  url=location.href;
	var wxdata;
		//alert(url.split("&")[0]);
		console.log(url.replace(/\&/g,"%26").replace(/\#/g,"%23"));
    $.ajax({
        type : "get",
        url : "http://live.scoringchina.com/scoringchina/wx/weixin_token/jssdk.php?url="+ url.replace(/\&/g,"%26").replace(/\#/g,"%23"),
        dataType : "jsonp",
        jsonp: "callback",
        jsonpCallback:"success_jsonpCallback",
        success : function(data){
			console.log(data);
			wxdata = data;
            wx.config({
                debug: false,
                appId: data.appId,
                timestamp: data.timestamp,
                nonceStr: data.nonceStr,
                signature: data.signature,
                jsApiList: [
                    'onMenuShareTimeline',//
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'onMenuShareQZone'
 
                ]
            });
			console.log(wxdata);
        },
        error:function(data){
           // alert("连接失败！");
        }
    });
 
    wx.ready(function () {
        var shareData = {
            title: '<?php echo $players['playerName'][$pl_id];?>-成绩卡-<?php echo $match_cn_name;?>-Scoring By 斯科云科技',
            desc: '<?php echo $course_name?>-Scoring By 斯科云科技',
            link: url,
           imgUrl: 'http://live.scoringchina.com/scoringchina/hnajunior/mobile/images/logo.png'
        };
		//alert(wxdata.url);
		//alert(url);
        wx.onMenuShareAppMessage(shareData);//分享给好友
        wx.onMenuShareTimeline(shareData);//分享到朋友圈
        wx.onMenuShareQQ(shareData);//分享给手机QQ
        wx.onMenuShareWeibo(shareData);//分享腾讯微博
        wx.onMenuShareQZone(shareData);//分享到QQ空间
 
 
 
    });
    wx.error(function (res) {
		console.log(res);
       //  alert(res.errMsg);//错误提示
 
    });
	
	/*  滚动到顶部*/
 $(function () {
   	 $("#go_top").hide();
   })
 
   //scroll() 方法为滚动事件  
   $(window).scroll(function(){
       if ($(window).scrollTop()>100){
          $("#go_top").fadeIn(800);
        }else{
          $("#go_top").fadeOut(800);
        }
    });
 
   /* //返回顶部按钮点击
    $("#go_top").click(function(){
       $('body,html').animate({scrollTop:0},100);
       return false;
    });*/
	
	function gotottop(){
		 $('body,html').animate({scrollTop:0},100);
       return false;
	}
	
</script>
<style>
 .up{width: 40px;height:40px; position:fixed; left:2vw;bottom:5vw;}
.index_news{padding:0 15px;}
#content {
    min-height: 360px;
    padding: 100px 15px 10px;

}
.score_back {
	text-align: right;
	padding-right: 14px;
}
.bt_back {
	display: inline-block;
	width: 40px;
	height: 18px;
	line-height: 18px;
	cursor: pointer;
	border: 1px solid #363636;
	color: #363636;
	font-size: 12px;
	text-align: center;
}
.pic{
	border-radius : 50%;
	width:80px;
	height:80px;
	margin-left:1px;
	padding:0px;
	object-fit: fill;
	
}
</style>

<style>
	#navi_wait {
		height: 35px;
		background-color: #E3E3E3;
	}

	#navi_wait ul li {
		width: 32%;
		display: inline;
		float: left;
		/*line-height:33px;*/

		line-height: 36px;
		list-style-position: inside;
		border-bottom: 1px solid #A5A5A5;
		text-align: center;
	}

	#navi_wait ul li a {
		color: #767676;
		font-size: 19px;
		letter-spacing: 5px;
	}
	.holebyhole{
		width:90%;
		height:90%;
		border-radius:10px;
		margin:auto auto auto auto;

	}
	
	.scoringtable{
		border-radius:10px;  border-collapse: collapse;  border-style:hidden;  box-shadow: 0 0 0 1px #d8d8d8; overflow:hidden;margin-top:10px;
	}
	
	.topartable{
		text-align:center;
		height:70px;
	}
	
	.topartable .num{
		height:40px;
		font-size:18px;
		font-weight:bolder;
		display:flex;
		justify-content:center;
		align-items:center;
	}
	
	.topartable .numdesc{
		height:30px;
		font-size:16px;
		font-weight:bold;
		background-color:<?php echo $color;?>;
		color:#fff;
		display:flex;
		justify-content:center;
		align-items:center;
	}
	
	.topar{
		width:80%;
		height:28px;
		border-radius:10px;
		margin:auto auto auto auto;
		color:#fff;
		display:flex;
		justify-content:center;
		align-items:center;
		
	}
	.undereven{
		font-weight:bolder;
		background-color:#B7001F; 
		color:#fff;
	}
	.even{
		font-weight:bolder;
		background-color:#53565A;
		color:#fff;
	}
	.pluseven{
		font-weight:bolder;
		background-color:#00438A;
		color:#fff;
	}
	
	
</style></head>
<body id="body">

	<div id="sta">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tbody>
				<tr>
					<td style="text-align:center;"><img src="./images/3.png" style="width:350px;height:80px" /></td>
				</tr>
			</tbody>
		</table>
    </div>

    <div id="content">
         <div style="margin-bottom:5px;"><font style="font-weight:bolder;font-size:17px;"><?php echo $match_cn_name?></font></div>
		<div class="tt_bar">
		  
			<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>
						<td class="score_title2"><div class="p_b" style="border-radius:5px;overflow:hidden;"><a style="background:url(./images/button_bg<?php echo $mp_class;?>.jpg)" href=""><?php echo $players['playerName'][$pl_id]?></a></div></td>
                        <?php 
                            if ($players['pl_photo'][$pl_id]){
                                echo '<td class="score_title2"><img style="border: 5px solid '.$color .'" class="pic"  src="../../admin/club/adm/images/players/'.$players['pl_photo'][$pl_id].'"  ></td>';
                            }
                        ?>
                        <td class="score_title2"></td>
						<td class="score_back"><div style="border-radius:5px;" class="bt_back radius_fillet3"><a href="index.php?mt_id=<?php echo $mt_id?>&rd_id=<?php echo $rd_id?>">返回</a></div></td>
					</tr>
				</tbody>
			</table>
		</div>
		

		

<?php 

$holeScore = getHoleScore($mt_id,$r=0,$pl_id);        //当前洞和当前轮的topar

echo 

     '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>';
				for($r=1;$r<=$maxRound;$r++){	
						echo '<td width="15%">
						   <div class="num"'. (($holeScore['thru'][$r][$pl_id] == 18 && $holeScore['roundtopar'][$r][$pl_id]<0)?'style="color:#e50049;"':'' ).'>'.$holeScore['roundscore'][$r][$pl_id].'</div>
						  <div class="numdesc">
						  R'.$r.'
					      </div>
						</td>';
				}
                $topar = $holeScore['totaltopar'][$pl_id];        
  echo'            <td width="20%">
					    <div class="num" '. (($holeScore['totalthru'][$pl_id]%18==0 && $topar<0)?'style="color:#e50049;"':'' ).'>'.$holeScore['totalscore'][$pl_id].'</div>
						  <div class="numdesc">
						  总杆
					      </div>
						</td>
						<td width="35%">
					    <div class="num"><div class="topar '.(($topar<0)?'undereven"':(($topar==0)?'even"':(($topar>0)?'pluseven"':'"'))).'>'.(($topar=='0') ? 'E' : (($topar=='') ? '' : (($topar>0) ? '+'.$topar : $topar))).'</div></div>
						  <div class="numdesc">
						 TOPAR
					      </div>
						</td>
				</tbody>
			</table>';


$eagles =   $birdies = $parcounts = $boegeys = $dbbogeys =  $worst = 0;
$par3 = $par4 = $par5 = 0;

for ($r=$maxRound;$r>=1;$r--){
    
	
	
	
    //if ($holeScore['score'][$r]){
	
	
	echo '<span class="p_b" style="height:20px; padding-left:20px;pading-top:5px;padding-bottom:5px; font-size:16px;">R'.($r).'</span>';
	
	
        echo '<table class="altrowstable scoringtable"><tbody>';
        echo '<tr>
                 <th style="background-color:'.$color.';color:#fff">洞</th>
                <th style="background-color:'.$color.';color:#fff">1</th>
                <th style="background-color:'.$color.';color:#fff">2</th>
                <th style="background-color:'.$color.';color:#fff">3</th>
                <th style="background-color:'.$color.';color:#fff">4</th>
                <th style="background-color:'.$color.';color:#fff">5</th>
                <th style="background-color:'.$color.';color:#fff">6</th>
                <th style="background-color:'.$color.';color:#fff">7</th>
                <th style="background-color:'.$color.';color:#fff">8</th>
                <th style="background-color:'.$color.';color:#fff">9</th>                    
                <th style="background-color:'.$color.';color:#fff">OUT</th>
            </tr>';
        echo '<tr class="odd_player">
                <td>标准杆</td>';
        $out_total = $in_total = 0;
        for ($i=1;$i<10;$i++){
            echo '<td>'.$pars["par"][($i-1)].'</td>';
            $out_total += $pars["par"][($i-1)];
        }
        echo '<td>'.$out_total.'</td></tr>';
        //成绩
        echo '<tr class="even_player"><td>成绩</td>';
        $out_score = $in_score = 0;
        for ($h=1;$h<10;$h++){
            echo '<td  class="'.toparcolor_detail($holeScore['topar'][$r][$pl_id][$h]).'">'.$holeScore['score'][$r][$pl_id][$h].'</td>';
            $out_score += $holeScore['score'][$r][$pl_id][$h];
			if($holeScore['score'][$r][$pl_id][$h]){
				if($pars["par"][($h-1)]==3){
					$par3 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($pars["par"][($h-1)]==4){
					$par4 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($pars["par"][($h-1)]==5){
					$par5 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($holeScore['topar'][$r][$pl_id][$h] <=-2){
					$eagles += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==-1){
					$birdies += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==0){
					$parcounts += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==1){
					$boegeys += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==2){
					$dbbogeys += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] >2){
					$worst += 1;
				}
			}
			
        }
        echo '<td style="background:#fff;color:#000;">'.$out_score.'</td></tr>';

        echo '<tr>
             <th style="background-color:'.$color.';color:#fff">洞</th>
                <th style="background-color:'.$color.';color:#fff">10</th>
                <th style="background-color:'.$color.';color:#fff">11</th>
                <th style="background-color:'.$color.';color:#fff">12</th>
                <th style="background-color:'.$color.';color:#fff">13</th>
                <th style="background-color:'.$color.';color:#fff">14</th>
                <th style="background-color:'.$color.';color:#fff">15</th>
                <th style="background-color:'.$color.';color:#fff">16</th>
                <th style="background-color:'.$color.';color:#fff">17</th>
                <th style="background-color:'.$color.';color:#fff">18</th>                    
                <th style="background-color:'.$color.';color:#fff">IN</th>
            </tr>';
        echo '<tr class="odd_player"><td>标准杆</td>';
        for ($i=10;$i<19;$i++){
            echo '<td>'.$pars["par"][($i-1)].'</td>';
            $in_total += $pars["par"][($i-1)];
        }
        echo '<td >'.$in_total.'</td></tr>';
        //成绩
        echo '<tr class="even_player"><td>成绩</td>';
        for ($h=10;$h<19;$h++){
            echo '<td class="'.toparcolor_detail($holeScore['topar'][$r][$pl_id][$h]).'">'.$holeScore['score'][$r][$pl_id][$h].'</td>';
            $in_score += $holeScore['score'][$r][$pl_id][$h];
			
			if($holeScore['score'][$r][$pl_id][$h]){
				if($pars["par"][($h-1)]==3){
					$par3 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($pars["par"][($h-1)]==4){
					$par4 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($pars["par"][($h-1)]==5){
					$par5 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($holeScore['topar'][$r][$pl_id][$h] <=-2){
					$eagles += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==-1){
					$birdies += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==0){
					$parcounts += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==1){
					$boegeys += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==2){
					$dbbogeys += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] >2){
					$worst += 1;
				}
			}
			
        }
        echo '<td style="background:#fff;color:#000;">'.$in_score.'</td></tr>';
        echo '</tbody></table>';
    //}       
}



echo 

     '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>
					   <td width="33%">
						   <div class="num"'. (($par3<0)?'style="color:#e50049;"':'' ).'>'.($par3>0?('+'.$par3):(($par3==0)?'E':$par3)).'</div>
						  <div class="numdesc">
							PAR 3s
					      </div>
						</td>
						 <td width="33%">
						   <div class="num"'. (($par4<0)?'style="color:#e50049;"':'' ).'>'.($par4>0?('+'.$par4):(($par4==0)?'E':$par4)).'</div>
						  <div class="numdesc">
							PAR 4s
					      </div>
						</td>
						 <td width="33%">
						   <div class="num"'. (($par5<0)?'style="color:#e50049;"':'' ).'>'.($par5>0?('+'.$par5):(($par5==0)?'E':$par5)).'</div>
						  <div class="numdesc">
							PAR 5s
					      </div>
						</td>
					</tr>		
				</tbody>
	 </table>';
	 

echo 

     '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>
					   <td width="33%">
						   <div class="num" style="color:#FFCC00;font-weight:bolder;">'.$eagles.'</div>
						  <div class="numdesc">
							老鹰
					      </div>
						</td>
						 <td width="33%">
							   <div class="num" style="color:red;font-weight:bolder;">'.$birdies.'</div>
						  <div class="numdesc">
							小鸟
					      </div>
						</td>
						 <td width="33%">
						  <div class="num" style="color:#53565A;font-weight:bolder;">'.$parcounts.'</div>
						  <div class="numdesc">
							帕
					      </div>
						</td>
					</tr>		
				</tbody>
	 </table>';

echo 

     '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>
					   <td width="33%">
						  <div class="num" style="color:#1E90FF;font-weight:bolder;">'.$boegeys.'</div>
						  <div class="numdesc">
							博忌
					      </div>
						</td>
						 <td width="33%">
							   <div class="num" style="color:#473D98;font-weight:bolder;">'.$dbbogeys.'</div>
						  <div class="numdesc">
							双博忌
					      </div>
						</td>
						 <td width="33%">
						  <div class="num" style="color:#000;font-weight:bolder;">'.$worst.'</div>
						  <div class="numdesc">
							+2以上
					      </div>
						</td>
					</tr>		
				</tbody>
	 </table>';
                  





function toparcolor_detail($score){
    if (!empty($score)){
        if ($score<='-2'){
            $color = 'eagle';
        } else if ($score=='-1'){
            $color = 'birdie';
        } else if ($score=='0'){
            $color = '';
        } else if ($score=='1'){
            $color = 'bogey';
        } else if ($score>='2'){
            $color = 'dbbogey';
        } else {
            $color = '';
        }
    } else {
        $color = '';
    }
    return $color;
}
?>  
    </div>

<div style="text-align:centre;display:none;justify-content: center;">
<img src="./images/ad.jpg" style="width:100%;height:100%">  </div>
	<img src="images/up.png" class="up" id="go_top" onclick="gotottop();">
<div id="bottom" style="background-color:#fff;text-align:centre;display:flex;justify-content: center;">
	<div id="bootom-top">
        <span style="width:100%;text-align:center">技术支持  @斯科云科技</span>
        <script type="text/javascript">document.write(unescape("%3Cspan id='cnzz_stat_icon_1279000992'%3E%3C/span%3E%3Cscript src='https://s4.cnzz.com/z_stat.php%3Fid%3D1279000992%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script>
		
	</div>
</div>
</body>
</html>